<?php

namespace app\model\questionnaire;

use app\BaseModel;
use app\model\UserModel;
use think\model\relation\BelongsTo;
use think\model\relation\HasMany;

/**
 * 问卷-试卷
 */
class QuestionnairePaperModel extends BaseModel
{
    protected $name = 'questionnaire_paper';

    /**
     * 发布人
     * @return BelongsTo
     */
    public function user(): BelongsTo
    {
        return $this->belongsTo(UserModel::class,'uid')->bind([
            'user_name' => 'name'
        ]);
    }

    /**
     * 问卷题目
     * @return HasMany
     */
    public function paperTopic(): HasMany
    {
        return $this->hasMany(QuestionnairePaperTopicModel::class, 'paper_id');
    }

    /**
     * 分类名称
     * @return BelongsTo
     */
    public function typeName(): BelongsTo
    {
        return $this->belongsTo(QuestionnaireTypeModel::class,'type_id')->bind([
            'type_name' => 'name'
        ]);
    }
}